package com.ctrip.corp.obt.shard.core;

import com.ctrip.corp.obt.generic.utils.ExceptionUtils;
import com.ctrip.corp.obt.generic.utils.StringPool;
import com.ctrip.corp.obt.generic.utils.StringUtils;

import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;

public class DataPlaneSource {

    private Set<String> tenantIds;

    private String source;

    public DataPlaneSource(String tenantIds, String source) {
        if (StringUtils.isBlank(source)) {
            throw ExceptionUtils.mpe("Invalid source, not allow to process");
        }
        if (StringUtils.isBlank(tenantIds)) {
            throw ExceptionUtils.mpe("Invalid tenantIds, not allow to process");
        }
        this.tenantIds = Arrays.stream(tenantIds.split(StringPool.COMMA)).map(String::trim).collect(Collectors.toSet());
        this.source = source;
    }

    public Set<String> getTenantIds() {
        return tenantIds;
    }

    public String getSource() {
        return source;
    }
}
